package com.koron.ticket.line.work.common.service;

import com.koron.bean.base.Response;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.ticket.feign.TicketChangeStatusFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: rocky
 * @Date: 2022/2/28 15:21
 */
@Service("lineOrderChangeStatusService")
@Slf4j
public class OrderChangeStatusService {

    private final static String STATUS = "IN_EXECUTE";

    private EamUser getCurrUser() {
        return ThreadLocalContext.get();
    }

    @Autowired
    TicketChangeStatusFeign feign;

    /**
     * 工作票许可审批后 变更 工单为执行中状态
     *
     * @param type
     * @param orderId
     */
    public void changeOrderStatus(String type, String orderId) {

        Response response = Response.fail();
        // 缺陷工单
        if (type.equals("defect")) {
            response = feign.submitDefect(orderId, STATUS);
        }

        // 计划检修工单
        if (type.equals("repair")) {
            response = feign.submitRepair(orderId, STATUS);
        }

        // 试验工单
        if (type.equals("experiment")) {
            response = feign.submitExperiment(orderId, STATUS);
        }

        // 维护工单
        if (type.equals("maintain")) {
            response = feign.submitMaintain(orderId, STATUS);
        }

        log.info("提交返回状态：{}",response.getCode());
        log.info("提交返回信息：{}",response.getDescription());
    }


}
